import ImagePicker from 'react-native-image-picker'


// More info on all the options is below in the README...just some common use cases shown here
const options = {
    title:'请选择',
    cancelButtonTitle:'取消',
    takePhotoButtonTitle:'拍照',
    chooseFromLibraryButtonTitle:'选择相册',
    videoQuality:'low' ,
    quality:.1,
    mediaType:"photo",
    allowsEditing:true,
    noData:false,
    storageOptions: {
        skipBackup: true,
        path:'images'
    }

};

/**
 * The first arg is the options object for customization (it can also be null or omitted for default options),
 * The second arg is the callback which sends object: response (more info below in README)
 */
export function showImagePicker(): Promise<any> {
    return new Promise(function (resolve, reject) {

        // @ts-ignore
        ImagePicker.showImagePicker(options, (response) => {
            console.log('Response = ', response);

            if (response.didCancel) {
                // reject('User cancelled image picker');
            }
            else if (response.error) {
                // reject(response.error);
            }
            else {
                resolve(response);
            }
        });
    })
}